#include <stdio.h>
#include <stdlib.h>

#define SIZE	100
typedef struct Lnode{
	double coe;
	int exp;
	struct Lnode* next;
}Lnode;

Lnode* InitDXSLNode(Lnode* l,int n)
{
	Lnode *p,*new_node,*pre;
	int i;
	l =(Lnode*)malloc(sizeof(Lnode)*SIZE);
	l->next =NULL;

	for(i =0;i<n;i++)
	{
		new_node =(Lnode*)malloc(sizeof(Lnode)*SIZE);
		scanf_s("%lf",&new_node->coe);
		scanf_s("%d",&new_node->exp);
		p =l->next;
		pre =l;
		while(p&&p->exp<new_node->exp)
		{
		  pre =p;
		  p =p->next;
		}
		new_node->next =p;
		pre->next =new_node;
	}
}

void SumLnode(Lnode* Pa,Lnode* Pb)
{
	Lnode *p1,*p2,*p3;
	p1 =Pa->next;
	p2 =Pb->next;
	p3 =Pa;
	while(p1&&p2)
	{
		if(p1->exp ==p2->exp)
		{
			if(p1->coe+p2->coe ==0)
			{
				p1->coe =p1->coe+p2->coe;
				p3->next =p1;
				p3 =p1;
				Lnode* tmp =p3;
				p3 =p3->next;
				free(p3);
			}
			else
			{
				Lnode* tmp =p1;
				p1 =p1->next;
				free(tmp);
				tmp =p2;
				p2 =p2->next;
				free(tmp);
			}
		}
		if(p1->exp<p2->exp)
		{
			p3->next =p1;
			p3 =p1;
			p1 =p1->next;
		}
		if(p1->exp>p2->exp)
		{
			p3->next =p2;
			p3 =p2;
			p2 =p2->next;
		}
		p3->next =p1?p1:p2;
		free(Pb);
	}
}

int main(void)
{

	while(1);
	return 0;
}